package com.maduar.demo.util;

import com.alibaba.fastjson.annotation.JSONField;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;

import java.io.Serializable;

/**
 * Description:
 *
 * @author danny.pang danny.pang@ebizprise.com
 * @date 2019-11-28 19:22
 */
@Getter
@Setter
@ToString
@AllArgsConstructor
@NoArgsConstructor
public class ErrorInfo implements Serializable{

    private static final long serialVersionUID = 2798143909637940294L;

    public static final String ILLEGAL_PARAMETER_CODE = "5000001";

    @JSONField(ordinal = 1)
    private String errorCode;
    @JSONField(ordinal = 2)
    private String errorMessage;

    public static ErrorInfo illegalParameter(String errorMessage) {
        return new ErrorInfo(ILLEGAL_PARAMETER_CODE, errorMessage);
    }

    public static ErrorInfo serviceError(String errorMessage) {
        return new ErrorInfo("5000002", errorMessage);
    }

    public static ErrorInfo unauthorizedError(String errorMessage) {
        return new ErrorInfo("5000401", errorMessage);
    }
}
